#! /bin/sh -e
#
# Pre-release checks for libpqxx.  Run from the subversion tag directory for the
# version that is to be released.
#
# Returns 0 if the branch appears ready for release.

PQXXVERSION="$(./tools/extract_version)"

# There must be no uncommitted changes.
check_uncommitted_changes() {
	local UNCOMMITTED_CHANGES
	UNCOMMITTED_CHANGES="$(svn st)"
	if test -n "$UNCOMMITTED_CHANGES"
	then
		cat <<EOF >&2
Branch has uncommitted changes:
$UNCOMMITTED_CHANGES
EOF
		exit 1
	fi
}


# We must be in the tag directory for the right release.
check_version_tag() {
	if ! pwd | grep -q "/tags/$PQXXVERSION$"
	then
		cat <<EOF >&2
This does not appear to be the tag directory for $PQXXVERSION.
EOF
		exit 1
	fi
}


./tools/lint
check_uncommitted_changes
check_version_tag
